//Nguyen Trung Hieu
import java.util.Vector;

public class Task implements Comparable<Object>{
	private String description;
	private String date;
	private String time;
	private String ID;
	private int oldPosition;
	TaskHandling OverdueHandling;
	
	public Task(String description,String date,String time, String ID){
		this.description = description;
		this.date = date;
		this.time = time;
		this.ID = ID;
	}

	public String getDescription(){
		return description;
	}
	
	public String getDate(){
		return date;
	}
	
	public String getTime(){
		return time;
	}
	
	public int getOldPosition(){
		return oldPosition;
	}
	
	public void setOldPosition (int oldPosition){
		this.oldPosition = oldPosition;
	}
	
	public TaskHandling getIsOverDue (){
		return OverdueHandling;
	}
	
	public void setIsOverDue (TaskHandling isOverdue){
		OverdueHandling = isOverdue;
	}
	
	public void setDescription(String description){
		this.description = description;
	}
	
	public void setDate(String date){
		this.date = date;
		
	}
	
	public void setTime(String time){
		this.time = time;
	}
	
	public String getID(){
		return ID;
	}
	
	public Long getIDInteger(){
		return Long.parseLong(ID);
	}
	
	public Object[] toArray(){
		Vector<String> attributes = new Vector<String> ();
		attributes.add(ID);
		attributes.add(description);
		attributes.add(time);
		attributes.add(date);
		return attributes.toArray();
		}

	@Override
	public int compareTo(Object obj) {
		Task tmp = (Task)obj;
		if(this.date.equals("")||this.time.equals(""))
			return 1;
		if(tmp.date.equals("")||tmp.time.equals(""))
			return -1;
		if(this.convertDeadline(this.date, this.time) < tmp.convertDeadline(tmp.date, tmp.time))
			return -1;
		else if(this.convertDeadline(this.date, this.time) > tmp.convertDeadline(tmp.date, tmp.time))
			return 1;
		else
			return 0;
	}
	
	public String readMonth(String month){
		if(month.equals("Jan"))
			return "01";
		if(month.equals("Feb"))
			return "02";
		if(month.equals("Mar"))
			return "03";
		if(month.equals("Apr"))
			return "04";
		if(month.equals("May"))
			return "05";
		if(month.equals("Jun"))
			return "06";
		if(month.equals("Jul"))
			return "07";
		if(month.equals("Aug"))
			return "08";
		if(month.equals("Sep"))
			return "09";
		if(month.equals("Oct"))
			return "10";
		if(month.equals("Nov"))
			return "11";
		return "12";
	}
	
	public Long convertDeadline(String date, String time){
		String[] dateSeg = date.split(" ");
		String[] timeSeg = time.split(":");
		String month = readMonth(dateSeg[0]);
		String deadlineString = dateSeg[2].concat(month.concat(dateSeg[1].concat(timeSeg[0].concat(timeSeg[1].concat(timeSeg[2])))));
		Long deadlineInt = Long.parseLong(deadlineString);
		return deadlineInt;
	}
}
